<?php
class Database{
	
	private $m_link;
	private $m_is_connected = false;
	
	public function connect($server, $user, $password, $dbname){
		try{
			$this->m_link = mysql_connect($server,$user,$password);
		}catch (Exception $e){
			echo($e->getMessage());
		}
		
		if( !$this->m_link ){
			$this->m_is_connected = false;
			return false;
		}
		mysql_select_db($dbname,$this->m_link);
		$this->m_is_connected = true;
		return true;
	}
	
	public function disconnect(){
		if($this->m_link)
		mysql_close($this->m_link);
	}
	
	public function query($sql){
		return mysql_query($sql,$this->m_link);
	}
}
?>